use std::path::PathBuf;
use structopt::StructOpt;

#[derive(Debug, StructOpt)]
pub struct Patch {
    /// The target process pid
    #[structopt(short, long)]
    pub pid: u32,

    /// The patch file to be installed
    #[structopt(name = "patch file", parse(from_os_str))]
    pub patch_file: PathBuf,
}

#[derive(Debug, StructOpt)]
pub struct Unpatch {
    /// The target process pid
    #[structopt(short, long)]
    pid: u32,

    /// The patch id of the patch to be uninstalled
    #[structopt(name = "patch id", short = "i", long = "id")]
    patch_id: String,
}

#[derive(Debug, StructOpt)]
pub struct Info {
    /// The target process pid
    #[structopt(short, long)]
    pid: u32,
}

#[derive(Debug, StructOpt)]
pub enum Action {
    /// Install the patch for the target process
    #[structopt(name = "patch")]
    #[structopt(display_order = 1)]
    Patch(Patch),

    /// Uninstall the patch for the target process
    #[structopt(name = "unpatch")]
    #[structopt(display_order = 2)]
    Unpatch(Unpatch),

    /// Query the patch information of the target process
    #[structopt(name = "info")]
    #[structopt(display_order = 3)]
    Info(Info),
}

/// Userspace live patch management tool
#[derive(StructOpt, Debug)]
#[structopt(name = "hotcure-ctl")]
pub struct Opts {
    // The patch management commands to be executed
    #[structopt(subcommand)]
    pub action: Action,

    /// verbose mode (-v, -vv, etc.)
    #[structopt(short, long, parse(from_occurrences))]
    verbose: u8,
}
